/**
 * Created by damir.ismailov on 15/12/2014.
 */
package simple.controller {
	import com.samoiloff.framework.controller.AbstractController;

	import flash.display.Sprite;
	import flash.events.MouseEvent;

	import simple.model.SimpleModel;

	import simple.view.SimpleView;

	public class SimpleRectangleClickController extends AbstractController {
		

		private var _model : SimpleModel;
		private var _view : SimpleView;

		public function SimpleRectangleClickController(view:SimpleView) {
			super(view);

			_view = view;
			_model = _view.model as SimpleModel;

			_view.rectangle.useHandCursor = _view.rectangle.buttonMode = true;

			_view.rectangle.addEventListener(MouseEvent.CLICK, onClick);
		}

		override public function destroy() : void {
			_view.rectangle.removeEventListener(MouseEvent.CLICK, onClick);

			super.destroy();
		}

		private function onClick(event : MouseEvent) : void {
			_model.displacement = !_model.displacement;
		}



	}
}
